package com.plian.system.wrapper.hr.dept;

import com.plian.system.dto.hr.dept.DeptDTO;
import com.plian.system.entity.hr.dept.Dept;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.hr.dept.DeptVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * 部门基础信息包装类,返回视图层所需的字段
 *
 * @author gangan
 * @since 2019-08-07
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface DeptWrapper extends BaseWrapper<Dept, DeptDTO, DeptVO> {

	@Override
	@Mappings(value = {
			@Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "deptAffiliation", target = "deptAffiliationName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "deptHigherId", target = "baseinfoDeptName", qualifiedByName = DEPT_ID_TO_NAME),
			@Mapping(source = "deptHead", target = "deptHeadName", qualifiedByName = STAFF_ID_TO_NAME)
	})
	DeptVO entityToVO(Dept entity);

}
